<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <script src="/static/header.js"></script>
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/systemctl/product?list=1&user={{ user }}">NANCAL</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a class="btn-group-sm" href="#">{{ user }}</a></li>
                <li><a class="btn-group-sm" href="/login/?close=1">退出</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                {% for i in  menu %}

                    {% if list == i.id %}
                        <li class="active"><a href="{{ i.url }}?list={{ i.id }}&user={{ user }}">{{ i.name }}<span class="sr-only">(current)</span></a></li>
                    {% else %}
                        <li><a href="{{ i.url }}?list={{ i.id }}&user={{ user }}">{{ i.name }}<span class="sr-only">(current)</span></a></li>
                    {% endif %}
                {% endfor %}

            </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">虚拟机</h1>

            <!--面板 开始-->
            <div class="panel panel-default">
                <div class="panel-heading"></div>
                <div class="panel-body">
                    <!--表格上面的那一行-->
                    <div class="row">
                    {% for i in  menu %}

                             {% if list == i.id %}
                                 <form class="form-horizontal" action="{{ i.url }}" method="GET">
                             {% endif %}
                           {% endfor %}
                    <div  class="col-sm-4">
                    {% for i in  menu %}
                             {% if list == i.id %}
                                 <input type="hidden" name="list" value="{{ i.id }}">
                                  <input type="hidden" name="user" value="{{ user }}">
                             {% endif %}
                           {% endfor %}
                    <select class="form-control" id="press_product_id" name="product_id" value="{{ product_id }}" onchange="productChange()">
                                    <option value="" >全部虚拟机</option>
                                    {% for i in  product_all %}
                                         {% if i.id == product_id %} <option value= {{ i.id }} selected="selected" >{{ i.name }}</option>{% endif %}
                                         {% if i.id != product_id %} <option value= {{ i.id }}>{{ i.name }}</option> {% endif %}
                                    {% endfor %}
                                </select>
                    </div>
                    <div  class="col-sm-4">
                            <button type="submit" class="btn btn-default bt" id="search_button">查询</button>
                        </div>
                        <div class="col-md-1 pull-right">
                            {% for mi in  menu %}
                                             {% if list == mi.id %}
                                                 <a class="btn btn-success pull-right" href="/git/add?list={{ list }}&user={{ user }}">添加</a>
                                             {% endif %}
                            {% endfor %}
                        </div>
                    </form>
                    </div>
                    <!--表格上面那一行 结束-->
                    <!--表格 开始-->
                    <div class="table-box">
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th class="text-center">序号</th>
                                <th class="text-center">HostName</th>
                                <th class="text-center">内网IP地址</th>
                                <th class="text-center">外网IP地址</th>
                                <th class="text-center">创建时间</th>
                                <th class="text-center">备注</th>
                                 <th class="text-center">操作</th>

                            </tr>
                            </thead>
                            <tbody>
                            {% for i in  ret %}
                            <tr class="text-center">
                                <td>{{ forloop.counter }}</td>
                                <td>{{ i.name }}</td>
                                <td>{{ i.inner_ip }}</td>
                                <td>{{ i.outer_ip }}</td>
                                <td>{{ i.create_date }}</td>
                                <td>{{ i.remark }}</td>
                            <td style="word-break: break-all;text-overflow: ellipsis;">
                                    <a class="btn btn-info btn-sm" href="/git/edit?list={{ list }}&id={{ i.id }}&user={{ user }}">编辑</a>
                                </td>
                            </tr>
                             {% endfor %}
                            <P>{{ error_msg  }}</P>
                            </tbody>
                        </table>
                    </div>

                    <!--表格 结束-->
                    <!--分页开始 style="color: #333; 337ab7"-->
                    <div>
                        <nav aria-label="Page navigation" class="pull-right">
                            <ul class="pagination">
                                {% for i in page.page_range %}
                                <li >
                                    {% if i == pageid %}
                                        {% for mi in  menu %}

                                             {% if list == mi.id %}
                                                  <a style="background-color: #EEE" href="{{ mi.url }}?list={{ list }}&user={{ user }}&page_id={{i}}">{{i}}</a>
                                             {% endif %}
                                           {% endfor %}

                                    {% endif %}
                                    {% if i != pageid %}
                                        {% for mi in  menu %}

                                             {% if list == mi.id %}
                                                  <a  href="{{ mi.url }}?list={{ list }}&user={{ user }}&page_id={{i}}">{{i}}</a>
                                             {% endif %}
                                           {% endfor %}
                                    {% endif %}
                                </li>
                                {% endfor %}
                            </ul>
                        </nav>
                    </div>
                    <!--分页结束-->
                </div>
            </div>
            <!--面板 结束-->
        </div>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/static/jquery-3.3.1.js"></script>
<script src="/static/bootstrap-3.3.7/js/bootstrap.js"></script>
<script>
    const search_button = document.getElementById('search_button')
    function productChange(){
        search_button.click()
    }
</script>
</body>
</html>